package com.yitiao.data_algorithms.leetcode.editor.cn;

import java.util.ArrayList;
import java.util.List;

class BinaryWatch {
    // 2023-02-17 17:52:42
    public static void main(String[] args) {
        Solution solution = new BinaryWatch().new Solution();
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    // Integer.bitCount(i); 返回二进制中1的个数
    class Solution {
        List<String> ans = new ArrayList();

        public List<String> readBinaryWatch(int turnedOn) {
            for (int i = 0; i < 12; i++) {
                int cur = turnedOn - Integer.bitCount(i);
                if (cur >= 0) {
                    for (int j = 0; j < 10; j++) {
                        if (Integer.bitCount(j) == cur) {
                            ans.add(new StringBuilder().append(i).append(":").append(0).append(j).toString());
                        }
                    }
                    for (int j = 10; j < 60; j++) {
                        if (Integer.bitCount(j) == cur) {
                            ans.add(new StringBuilder().append(i).append(":").append(j).toString());
                        }
                    }
                }
            }
            return ans;
        }
    }

//leetcode submit region end(Prohibit modification and deletion)

}